<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateComCitiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('com_cities')){

            Schema::create('com_cities', function (Blueprint $table) {
                $table->integer('id')->primary()->comment('ID');
                $table->string('parent_id', 45)->comment('上级ID');
                $table->text('paths')->comment('ID路径（id,id,id）');
                $table->string('name', 45)->comment('名称');
                $table->string('code', 45)->nullable()->comment('代码');
                $table->integer('level')->nullable()->comment('层级');
                $table->tinyInteger('is_city')->nullable()->default(0)->comment('是否市级');
                $table->tinyInteger('top')->nullable()->default(0)->comment('是否置顶 1是 0否');
                $table->integer('sort')->default(0)->nullable()->comment('排序权重');
                $table->integer('child')->default(0)->nullable()->comment('子节点数量');
                $table->double('lng')->nullable()->comment('纬度');
                $table->double('lat')->nullable()->comment('经度');
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('com_cities');
    }
}
